Page({

  /**
   * 页面的初始数据
   */
  data: {
    background: [],
    indicatorDots: true,
    vertical: false,
    autoplay: false,
    interval: 2000,
    duration: 500,
    sencinData: [],
    bannerList:[],
    sid:0,
    createTime:'',
    createTimes:'',
    commentList:[],
    commentNum:0,
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    wx.setNavigationBarTitle({
      title: '攻略详情',
    })
    let that = this
    wx.getStorage({
      key:'sid',
      success(res){
        that.setData({
          sid:res.data
        })
        wx.request({
          url: 'https://wwz.jingyi.icu/app/intro/index',
          data:{
            scenic_id:that.data.sid
          },
          method: 'POST',
          success: (res) => {
            console.log(res);
            that.setData({
              sencinData: res.data.data[0],
            })
            console.log(that.data.sid);
            console.log(that.data.sencinData);
            let baner = res.data.data[0].bannar.split(',')
            for(let i = 0;i < baner.length ;i++){
              baner[i] = 'https://wwz.jingyi.icu'+baner[i]
            }
            console.log(that.data.sencinData.create_time);
            
            that.setData({
              background:baner,
              createTime:that.data.sencinData.create_time.substring(0, 10),
              createTimes:that.data.sencinData.create_time.substring(0, 10)
            })
            console.log(res.data.data[0].id);
            wx.request({
              url: 'https://wwz.jingyi.icu/app/Introcom/index',
              data:{
                intri_id:res.data.data[0].id
              },
              method: 'POST',
              success: (res) => {
                console.log(res.data.data);
                that.setData({
                  commentNum:res.data.data.length
                })
                let obj = {}
                let arrs = []
                for(let item of res.data.data){
                  console.log(item);
                  obj = item
                  obj.imgs = []
                  if(obj.avatar.substring(0, 1) == '/'){
                    obj.avatar = 'https://wwz.jingyi.icu/'+obj.avatar
                  }else{
                    console.log('略略略');
                  }
                  let vals = []
                  console.log(item);
                  console.log(item.img);
                  vals = item.img.split(',')
                  console.log(vals);
                  for(let im of vals){
                    console.log(im);
                    obj.imgs.push('https://wwz.jingyi.icu/'+im)
                  }
                  item.create_time = item.create_time.substring(0, 10)
                  arrs.push(obj)
                }
                console.log('-----------------');
                console.log(arrs);
                that.setData({
                  commentList:arrs
                })
                console.log(that.data.commentList);
                console.log('-----------------');
              }
            })
            console.log(that.data.background);
          }
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  }
})